﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// AGV调度任务记录
    /// </summary>
    public partial class AgvDispatchTask : BusEntity
    {
        /// <summary>
        /// 起点位置编码
        /// </summary>
        public string StartCode { set; get; }
        /// <summary>
        /// 目标位置编码
        /// </summary>
        public string TargetCode { set; get; }
        /// <summary>
        /// Agv任务类型(CF_Enum.Code=AgvTaskType)
        /// </summary>
        public string TaskType { set; get; }
        /// <summary>
        /// Agv任务状态(CF_Enum.Code=AgvTaskStatus)
        /// </summary>
        public string TaskStatus { set; get; }
        /// <summary>
        /// 调度时间
        /// </summary>
        public DateTime DispatchTime { set; get; }
        /// <summary>
        /// 完成时间
        /// </summary>
        public DateTime? CompletionTime { set; get; }
        /// <summary>
        /// 耗时(单位：分钟)
        /// </summary>
        public int ElapsedTime { set; get; }
    }

    public partial class AgvDispatchTask : BusEntity
    {
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class AgvDispatchTaskTypeConfig : BusEntityTypeConfig<AgvDispatchTask>, IEntityTypeConfiguration<AgvDispatchTask>
    {
        public override void Configure(EntityTypeBuilder<AgvDispatchTask> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.StartCode).HasMaxLength(EntityDefinition.DefLittleColLen).IsRequired();
            builder.Property(p => p.TargetCode).HasMaxLength(EntityDefinition.DefLittleColLen).IsRequired();
            builder.Property(p => p.TaskType).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.TaskStatus).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.DispatchTime).IsRequired();
            builder.Property(p => p.CompletionTime);
            builder.Property(p => p.ElapsedTime);
            #endregion

            #region 备注
            builder.HasComment("AGV调度任务记录");
            builder.Property(p => p.StartCode).HasComment("起点位置编码");
            builder.Property(p => p.TargetCode).HasComment("目标位置编码");
            builder.Property(p => p.TaskType).HasComment("Agv任务类型(CF_Enum.Code=AgvTaskType)");
            builder.Property(p => p.TaskStatus).HasComment("Agv任务状态(CF_Enum.Code=AgvTaskStatus)");
            builder.Property(p => p.DispatchTime).HasComment("调度时间");
            builder.Property(p => p.CompletionTime).HasComment("完成时间");
            builder.Property(p => p.ElapsedTime).HasComment("耗时(单位：分钟)");
            #endregion

            #region 种子数据
            #endregion
        }
    }
}
